package com.gict.antifraudback.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gict.antifraudback.entity.ArticleComment;
import com.gict.antifraudback.service.ArticleCommentService;
import com.gict.antifraudback.mapper.ArticleCommentMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* @author XIE
* @description 针对表【article_comment】的数据库操作Service实现
* @createDate 2023-11-02 15:18:53
*/
@Service
public class ArticleCommentServiceImpl extends ServiceImpl<ArticleCommentMapper, ArticleComment>
    implements ArticleCommentService{

    @Override
    public Integer countByArticleId(Integer id) {
        LambdaQueryWrapper<ArticleComment> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ArticleComment::getArticleId, id);
        return count(wrapper);
    }

    @Override
    public Collection<ArticleComment> listChildrenByIds(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return new ArrayList<>();
        }
        LambdaQueryWrapper<ArticleComment> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ArticleComment::getParentCommentId, ids);
        return list(wrapper);
    }
}




